/*
 * Copyright © 2022-now 尛飛俠（Denvie） All rights reserved.
 */

package cn.denvie.springcloud.user.interceptor;

import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Component;
import org.springframework.util.ObjectUtils;
import org.springframework.web.servlet.HandlerInterceptor;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

/**
 * BasicAuthenticateInterceptor。
 *
 * @author Denvie
 * @date 2022/3/30
 * @since 1.0.0
 */
@Slf4j
@Component
public class BasicAuthenticateInterceptor implements HandlerInterceptor {
    @Override
    public boolean preHandle(HttpServletRequest request, HttpServletResponse response, Object handler) throws Exception {
        // 从请求头中获取授权信息
        String authorization = request.getHeader("Authorization");
        if (!ObjectUtils.isEmpty(authorization)) {
            log.debug("Authorization == {}", authorization);
        }
        return true;
    }
}
